package
{
	import com.tommy.ddp.DdpContainer;
	import com.tommy.ddp.IDdpGame;
	import com.tommy.ddp.MainManager;
	import com.tommy.ddp.definition.DDPConfig;
	import com.tommy.ddp.manager.FillUpManager2;
	import com.tommy.ddp.manager.PipelineDataManager;
	
	import flash.geom.Rectangle;
	import flash.utils.setTimeout;
	
	import starling.core.Starling;
	import starling.display.DisplayObjectContainer;
	import starling.display.Sprite;
	import starling.events.Event;
	import starling.text.TextField;
	
	public class Game extends Sprite implements IDdpGame
	{
		private var _txt:TextField;
		private var _container:DdpContainer;
		
		public function Game()
		{
			super();
			MainManager.init(this);
			FillUpManager2.init();
			
			this.addEventListener(Event.ADDED_TO_STAGE,onAdded);
		}
		
		public function get container():DdpContainer
		{
			return _container;
		}
		
		private function onAdded(event:Event):void
		{
			//Starling.current.nativeStage.stageWidth;
			//Starling.current.nativeStage.stageHeight;
			stage.stageWidth = Starling.current.nativeStage.stageWidth;
			stage.stageHeight = Starling.current.nativeStage.stageHeight;
			Starling.current.viewPort = new Rectangle(0,0,Starling.current.nativeStage.stageWidth,Starling.current.nativeStage.stageHeight);
			
			_container = new DdpContainer;
			//_container.clipRect = new Rectangle(0,0,DDPConfig.GRID_SIZE_W*DDPConfig.W_NUM,DDPConfig.GRID_SIZE_H*DDPConfig.H_NUM);
			_container.x = 30;
			_container.y = 300;
			addChild(_container);
			//
			_txt = new TextField(100,30,"Debug Info");
			_txt.color = 0xffffff;
			_txt.x = 30;
			_txt.y = 50;
			addChild(_txt);
			
			
			var txt:TextField = new TextField(100,80,"");
			txt.x = 245;
			txt.y = 10;
			txt.color = 0xffffff;
			addChild(txt);
			//txt.text = "SB：彩球炸弹\rB：会炸9格的\rBC：B消除产生的\rX：X轴全消\rY：Y轴全消";
			txt.text = stage.stageWidth+","+stage.stageHeight;
		}
		
		
		public function set tips(str:String):void
		{
			_txt.text = str;
			/*setTimeout(function():void
			{
				_txt.text = "";
			},1000);*/
		}
		
	}
}



/**
 BUG：
 
 SB在消除的时候会把同色的BC也消除
 
 */